//
//  HMStatusBottomView.swift
//  HMWeibo1
//
//  Created by liGordon on 16/4/14.
//  Copyright © 2016年 lifuli. All rights reserved.
//

import UIKit



class HMStatusBottomView: UIView {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
         prepareUI()
    }
    
    private func prepareUI() {
        // 1. 添加子控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        // 2.添加约束
        // 转发按钮
        retweetButton.snp_makeConstraints { (make) -> Void in
           make.leading.top.bottom.equalTo(self)
            }
        
        // 评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(retweetButton.snp_trailing)
            make.top.bottom.equalTo(self)
            
            make.width.equalTo(retweetButton)
        }
        
        // 赞按钮
        likeButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(commentButton.snp_trailing)
            make.top.trailing.bottom.equalTo(self)
            
            make.width.equalTo(retweetButton)
        }
        
    }
    
    
    //Mark: - 懒加载
    /// 转发按钮
    private lazy var retweetButton: UIButton = {
        let button = UIButton()
        
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        
        // 设置按钮图片
        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        
        // 设置按钮标题
        button.setTitle("转发", forState: UIControlState.Normal)
        
        return button

    }()
    
    /// 评论按钮
    private lazy var commentButton: UIButton = {
        let button = UIButton()
        
        // 设置按钮背景图片
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        
        // 设置按钮图片
        button.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        
        // 设置按钮标题
        button.setTitle("评论", forState: UIControlState.Normal)
        
        return button
    }()
    
    /// 赞
    private lazy var likeButton: UIButton = {
        let button = UIButton()
        
        // 设置按钮背景图片
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        
        // 设置按钮图片
        button.setImage(UIImage(named: "timeline_icon_unlike"), forState: UIControlState.Normal)
        
        // 设置按钮标题
        button.setTitle("赞", forState: UIControlState.Normal)
        
        return button
    }()
    
}


